package com.xulinhao.dao.impl;/**
 * @author xulinhao
 * @create 2021-06-02 15:36
 */

import com.xulinhao.dao.OrderItemDao;
import com.xulinhao.pojo.Book;
import com.xulinhao.pojo.Order;
import com.xulinhao.pojo.OrderItem;

import java.util.List;

/**
 * @Author xlh
 * @packagename: com.xulinhao.dao.impl
 * @classname: OrderItemDaoImpl
 * @Description:
 * @Date 2021/6/2
 */
public class OrderItemDaoImpl extends BaseDao implements OrderItemDao {
    @Override
    public int saveOrderItem(OrderItem orderItem) {
        String sql = "insert into t_order_item(`name`,`count`,`price`,`total_price`,`order_id`) values(?,?,?,?,?)";
        return update(sql,orderItem.getName(),orderItem.getCount(),orderItem.getPrice(),orderItem.getTotalPrice(), orderItem.getOrderId());
    }

    @Override
    public List<OrderItem> queryOrderItemsByOrderId(String orderId) {
        String sql = "select `name`,`count`,`price`,`total_price` totalPrice from t_order_item where `order_id`=? ";
        return queryForList(OrderItem.class, sql,orderId);
    }
}
